package org.xhy.retryerboot.proxy;

import org.springframework.cglib.proxy.Enhancer;
import org.xhy.retryer.core.Retryer;

import java.util.Map;

/**
 * @description: 通用的 cglib 代理工厂
 * @gitee: https://gitee.com/XhyQAQ
 * @copyright: B站: https://space.bilibili.com/152686439
 * @Author: Xhy
 * @CreateTime: 2024-05-01 11:31
 */
public class ProxyFactory {

    public static Object createdProxy(Object target, RetryerProxy retryerProxy){
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(target.getClass());
        enhancer.setCallback(retryerProxy);
        return enhancer.create();
    }
}
